//
//  L2Tab7.m
//  Lesson2
//
//  Created by Alexander Trifonov on 20.04.12.
//  Copyright (c) 2012 fgengine@gmail.com. All rights reserved.
//

#import "L2Tab7.h"

@implementation L2Tab7

CGFloat R2D(CGFloat r)
{
    return r * 180 / M_PI;
};

- (void) viewDidLoad
{
    [super viewDidLoad];
    [[UIAccelerometer sharedAccelerometer] setUpdateInterval:(1.0 / 30.0)];
    [[UIAccelerometer sharedAccelerometer] setDelegate:self];
}

- (void) accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration
{
	float angle = -R2D(atan2([acceleration y], -[acceleration x]));
    image.transform = CGAffineTransformRotate(image.transform, angle);
}

@end
